package com.lenovo.manufacture.view;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.lenovo.manufacture.R;
import com.lenovo.manufacture.bean.JianKongBean;

public class MyPopupWindow extends PopupWindow implements View.OnClickListener {
    private Context context;
    private View view;

    TextView tvPopStep;
    TextView tvPopName;
    ProgressBar pbPopPower;
    TextView tvPopPower;
    Button tvPopRepair;

    public MyPopupWindow(Context context) {
        super(context);
        this.context = context;
        setHeight((int)(130*1.75+0.5f));
        setWidth((int)(150*1.75+0.5f));
        setOutsideTouchable(true);
        setTouchable(true);
        setFocusable(true);
        setBackgroundDrawable(new BitmapDrawable());
        view = View.inflate(context, R.layout.my_popupwindow, null);

        tvPopStep = view.findViewById(R.id.tv_pop_step);
        tvPopName = view.findViewById(R.id.tv_pop_name);
        pbPopPower = view.findViewById(R.id.pb_pop_power);
        tvPopPower = view.findViewById(R.id.tv_pop_power);
        tvPopRepair = view.findViewById(R.id.tv_pop_repair);
        tvPopRepair.setOnClickListener(this);

        setContentView(view);
    }

    public void changeInfo(JianKongBean.DataBean data) {
        tvPopStep.setText("第" + data.getStep() + "步");
        tvPopName.setText(data.getPlStepName());
        pbPopPower.setProgress(data.getPower());
        tvPopPower.setText("耐久度 " + data.getPower());
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.tv_pop_repair) {

        }
    }
}
